<?php
namespace app\manage\controller;
use think\Controller;
use think\Db;
use app\manage\model\Config as ConfigModel;

class Config extends Common{
  public function index($tab = "1"){
    if(request()->isPost()){
      $config = new ConfigModel;
      if($config->saveConfig(input('post.'))){
          return success('配置更新成功!',url('index',['tab'=>$tab]));
      }else{
          return error('配置更新失败!',url('index',['tab'=>$tab]));
      }
    }else{
      $configList = ConfigModel::column('config_varname,config_value');
      $this->assign('site',$configList);
      return view();
    }
  }
    public function uploadImg()
    {
        if (request()->isAjax()) {
            $file = request()->file('file');
            // 移动到框架应用根目录/public/uploads/ 目录下
            $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
            if ($info) {
                $src = '/public/uploads' . '/' . date('Ymd') . '/' . $info->getFilename();
                return (['src' => $src]);
            } else {
                // 上传失败获取错误信息
                return $file->getError();
            }
        }
    }
}


?>
